package com.example.demo.controller;

import com.example.demo.service.Search;
import com.example.demo.valueObject.AntiCounterfeiting;
import com.sun.org.apache.bcel.internal.generic.INSTANCEOF;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;

@org.springframework.stereotype.Controller
public class Controller {
    @Autowired
    private Search search;
    @GetMapping("/页面.php")
    public String searchById(@RequestParam("id")String id, HttpServletRequest request)
    {
        Object o = search.SearchById(id.trim());
        if(o instanceof AntiCounterfeiting)
        {
            request.setAttribute("AntiCounterfeiting",o);
            request.setAttribute("code","200");
        }else
        {
            request.setAttribute("describe",o.toString());
            request.setAttribute("code","300");
        }
        return "1";
    }
}
